<style>
    html{
        background-color: #f2f2f2;
    }
    .content-body{
        background-color: transparent;
    }
    /* 卡片面板 */
    .layui-card{margin-bottom: 10px; border-radius: 2px; background-color: #fff; box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);}
    .layui-card:last-child{margin-bottom: 0;}
    .layui-card-header{position: relative; height: 42px; line-height: 42px; padding: 0 15px; border-bottom: 1px solid #f6f6f6; color: #333; border-radius: 2px 2px 0 0; font-size: 14px;}
    .layui-card-body{position: relative; padding: 10px 15px; line-height: 24px;}
    th,td{
        text-align: center;
    }
</style>

<div class="container-fluid">
    <div class="row layui-card">
        <div class="layui-card-body">
            <a href="{:url('index/index')}">主页</a>
            <span>/</span>
            <span>大型仪器统计</span>
        </div>
    </div>

    <div class="row layui-card">
        <div class="layui-card-header" style="height: 45px;">
            <div class="form-inline">

                    <label>归档年月</label>
                    <input name="archive_yearmonth" value="{$archive_yearmonth}" class="form-control" style="width: 120px;">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <label>隶属单位</label>
                    <select name="statisticsType" class="form-control" style="width: 120px;">
                        <option value="天津大学" {if $statisticsType=='天津大学'}selected{/if}>天津大学</option>
                        <option value="附中" {if $statisticsType=='附中'}selected{/if}>附中</option>
                        <option value="附小" {if $statisticsType=='附小'}selected{/if}>附小</option>
                        <option value="内燃所" {if $statisticsType=='内燃所'}selected{/if}>内燃所</option>
                    </select>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <button class="btn btn-info btn-sm" onclick="getInfo()">统计</button>
                    &nbsp;&nbsp;
                    <button class="btn btn-default btn-sm" onclick="printTable()">打印表格</button>
                    &nbsp;&nbsp;
                    <button class="btn btn-success btn-sm" onblur="export_excel()">导出Excel</button>
            </div>
        </div>

        <div class="layui-card-body">
            <div class="col-sm-3">
                <span>参与统计的院处级单位</span>
                    <div style="border: 1px solid #ddd;width: 100%;height: 500px;padding-left: 10px;overflow-y:auto">
                        <div style="text-align:left">
                            &nbsp;已选定单位：<br>

                            {volist name="college_selected_list" id="vo"}
                            <input name=collegeList[] type=checkbox value="{$vo}" checked="checked">{$vo}<br>
                            {/volist}
                        </div>
                        <br/>
                        <div style="text-align:left">
                            &nbsp;学院列表：<br>{volist name="college_list" id="vo"}
                            <input name=collegeList[] type=checkbox value="{$vo['COLLEGE_NAME']}">{$vo['COLLEGE_NAME']}<br>
                            {/volist}
                        </div>
                        <br/>
                        <div style="text-align:left">
                            &nbsp;非学院列表：<br>{volist name="no_college_list" id="vo"}
                            <input name=collegeList[] type=checkbox value="{$vo['COLLEGE_NAME']}">{$vo['COLLEGE_NAME']}<br>
                            {/volist}
                        </div>

                    </div>
                    &nbsp;<button class="btn btn-info btn-sm" style="margin-top: 20px" onclick="getInfo()">重新统计</button>
            </div>
            <div class="col-sm-9" style="height: 600px;overflow-y:auto ">
                <span>面积：平方米&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价值：元</span>

                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>所属单位</th>
                        <th>下级部门</th>
                        <th>价值区间</th>
                        <th>数量</th>
                        <th>价值（元）</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="fin_list" id="vo"}
                    {if $key == 0}
                    <tr>
                        <th rowspan="{$row_num}">&nbsp;{$title}</th>
                        <th rowspan="5">&nbsp;{$vo[0]}</th>
                        <td>&nbsp;{$vo[1]}</td>
                        <td>&nbsp;{$vo[2]}</td>
                        <td class="lr">&nbsp;{$vo[3]}</td>
                    </tr>
                    <tr>
                        <td>{$vo[4]}</td>
                        <td>&nbsp;{$vo[5]}</td>
                        <td class="lr">&nbsp;{$vo[6]}</td>
                    </tr>
                    <tr>
                        <td>{$vo[7]}</td>
                        <td>&nbsp;{$vo[8]}</td>
                        <td class="lr">&nbsp;{$vo[9]}</td>
                    </tr>
                    <tr>
                        <td>{$vo[10]}</td>
                        <td>&nbsp;{$vo[11]}</td>
                        <td class="lr">&nbsp;{$vo[12]}</td>
                    </tr>
                    <tr>
                        <td>合计</td>
                        <td>&nbsp;{$vo[13]}</td>
                        <td class="lr">&nbsp;{$vo[14]}</td>
                    </tr>
                    {else/}
                    <tr>
                        <th rowspan="5">&nbsp;{$vo[0]}</th>
                        <td>&nbsp;{$vo[1]}</td>
                        <td>&nbsp;{$vo[2]}</td>
                        <td class="lr">&nbsp;{$vo[3]}</td>
                    </tr>
                    <tr>
                        <td>{$vo[4]}</td>
                        <td>&nbsp;{$vo[5]}</td>
                        <td class="lr">&nbsp;{$vo[6]}</td>
                    </tr>
                    <tr>
                        <td>{$vo[7]}</td>
                        <td>&nbsp;{$vo[8]}</td>
                        <td class="lr">&nbsp;{$vo[9]}</td>
                    </tr>
                    <tr>
                        <td>{$vo[10]}</td>
                        <td>&nbsp;{$vo[11]}</td>
                        <td class="lr">&nbsp;{$vo[12]}</td>
                    </tr>
                    <tr>
                        <td>合计</td>
                        <td>&nbsp;{$vo[13]}</td>
                        <td class="lr">&nbsp;{$vo[14]}</td>
                    </tr>
                    {/if}
                    {/volist}
                    {if $row_num==5}
                    <td rowspan="6">{$statisticsType}</td>
                    {/if}
                    <tr>
                        <th rowspan="5">合计</th>
                        <td>10万-40万（含10万）</td>
                        <td>&nbsp;{$total_10_sum_num}</td>
                        <td class="lr">&nbsp;{$total_10_sum_price}</td>
                    </tr>
                    <tr>
                        <td>40万-100万（含40万）</td>
                        <td>&nbsp;{$total_40_sum_num}</td>
                        <td class="lr">&nbsp;{$total_40_sum_price}</td>
                    </tr>
                    <tr>
                        <td>100万-200万（含100万）</td>
                        <td>&nbsp;{$total_100_sum_num}</td>
                        <td class="lr">&nbsp;{$total_100_sum_price}</td>
                    </tr>
                    <tr>
                        <td>200万以上（含200万）</td>
                        <td>&nbsp;{$total_200_sum_num}</td>
                        <td class="lr">&nbsp;{$total_200_sum_price}</td>
                    </tr>

                    <tr>
                        <td>合计</td>
                        <td>&nbsp;{$total_10_sum_num+$total_40_sum_num+$total_100_sum_num+$total_200_sum_num}</td>
                        <td class="lr">&nbsp;{$total_10_sum_price+$total_40_sum_price+$total_100_sum_price+$total_200_sum_price}</td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <div class="row layui-card">
        <div id="chart-num" style="width: 100%;height: 600px;padding-top: 30px"></div>
    </div>
    <div class="row layui-card">
        <div id="chart-price" style="width: 100%;height: 600px;padding-top: 30px"></div>
    </div>
</div>

<script src="__STATIC__/js/echarts.min.js"></script>

<script>

    var fin_list = {:json_encode($fin_list)};
    var numChart = echarts.init(document.getElementById('chart-num'));
    var priceChart = echarts.init(document.getElementById('chart-price'));
    // 学院列表 数据列表
    var collegeNames = [];
    var series_num1 = [];
    var series_num2 = [];
    var series_num3 = [];
    var series_num4 = [];

    var series_price1 = [];
    var series_price2 = [];
    var series_price3 = [];
    var series_price4 = [];

    for (var i in fin_list)
    {
        collegeNames.push(fin_list[i][0]);
        series_num1.push(fin_list[i][2]);
        series_num2.push(fin_list[i][5]);
        series_num3.push(fin_list[i][8]);
        series_num4.push(fin_list[i][11]);

        series_price1.push(fin_list[i][3]);
        series_price2.push(fin_list[i][6]);
        series_price3.push(fin_list[i][9]);
        series_price4.push(fin_list[i][12]);
    }

    // 指定图表的配置项和数据--数量
    var option_num = {
        title: {
            text: '大型仪器统计--数量'
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {
                type : 'shadow'
            }
        },
        legend: {
            data:['10万-40万（含10万）','40万-100万（含40万）','100万-200万（含100万）','200万以上（含200万）']
        },
        xAxis: {
            data: collegeNames
        },
        yAxis: {},
        series: [{
            name: '10万-40万（含10万）',
            type: 'bar',
            barWidth:"20%",
            data: series_num1
        },{
            name: '40万-100万（含40万）',
            type: 'bar',
            barWidth:"20%",
            data: series_num2
        },{
            name: '100万-200万（含100万）',
            type: 'bar',
            barWidth:"20%",
            data: series_num3
        },{
            name: '200万以上（含200万）',
            type: 'bar',
            barWidth:"20%",
            data: series_num4
        }]
    };

    // 指定图表的配置项和数据--价值

    var option_price = {
        title: {
            text: '大型仪器统计--价值'
        },
        tooltip : {
            trigger: 'axis',
            axisPointer : {
                type : 'shadow'
            }
        },
        legend: {
            data:['10万-40万（含10万）','40万-100万（含40万）','100万-200万（含100万）','200万以上（含200万）']
        },
        xAxis: {
            data: collegeNames
        },
        yAxis: {},
        series: [{
            name: '10万-40万（含10万）',
            type: 'bar',
            barWidth:"20%",
            data: series_price1
        },{
            name: '40万-100万（含40万）',
            type: 'bar',
            barWidth:"20%",
            data: series_price2
        },{
            name: '100万-200万（含100万）',
            type: 'bar',
            barWidth:"20%",
            data: series_price3
        },{
            name: '200万以上（含200万）',
            type: 'bar',
            barWidth:"20%",
            data: series_price4
        }]
    };
    // 使用刚指定的配置项和数据显示图表。
    numChart.setOption(option_num);
    priceChart.setOption(option_price);


    // 获取统计数据
    function getInfo() {
        var collegeList = [];

        $.each($('input:checkbox:checked'),function(){
            collegeList.push($(this).val());
        });
        var archive_yearmonth = $("input[name=archive_yearmonth]").val();
        var statisticsType = $("select[name=statisticsType]").val();

        var url = "{:url('statistics/largeInstrumentsBasicInfo')}?archive_yearmonth="+archive_yearmonth+"&collegeList="+collegeList+"&statisticsType="+statisticsType;
        location.href = url;
    }
    // 打印表格
    function printTable() {
        var collegeList = [];

        $.each($('input:checkbox:checked'),function(){
            collegeList.push($(this).val());
        });
        var archive_yearmonth = $("input[name=archive_yearmonth]").val();
        var statisticsType = $("select[name=statisticsType]").val();

        var url = "{:url('statistics/largeInstrumentsBasicInfoPrint')}?archive_yearmonth="+archive_yearmonth+"&collegeList="+collegeList+"&statisticsType="+statisticsType;
        window.open(url);
    }

</script>